package com.basic.modules.ykf.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.basic.common.utils.ParamsModel;
import com.basic.common.utils.ParamUtils;
import com.basic.modules.ykf.dao.YkfShopChangeRecordDao;
import com.basic.modules.ykf.entity.YkfShopChangeRecordEntity;
import com.basic.modules.ykf.service.YkfShopChangeRecordService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.basic.common.utils.PageUtils;
import com.basic.common.utils.Query;



@Service("ykfShopChangeRecordService")
public class YkfShopChangeRecordServiceImpl extends ServiceImpl<YkfShopChangeRecordDao, YkfShopChangeRecordEntity> implements YkfShopChangeRecordService {

    @Override
    public PageUtils queryPage(ParamsModel<YkfShopChangeRecordEntity> params) {
        QueryWrapper<YkfShopChangeRecordEntity> queryWrapper = ParamUtils.createQueryWrapperBySort(params);
        if (ObjectUtil.isEmpty(params.getSort()) || StrUtil.isBlank(params.getSort().getSidx()) || StrUtil.isBlank(params.getSort().getOrder())) {
            queryWrapper.lambda().orderByDesc(YkfShopChangeRecordEntity::getCreateTime);
        }
        IPage<YkfShopChangeRecordEntity> page = this.page(
                new Query<YkfShopChangeRecordEntity>().getPage(BeanUtil.beanToMap(params.getPage())),
                queryWrapper
        );
        return new PageUtils(page);
    }

}
